<template>
    <div class="modal fade" id="addAppealModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content">
          	<div class="modal-header">
            	<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
            	<h4 class="modal-title" id="myModalLabel">发起申诉</h4>
          	</div>
          	<div class="modal-body">
          	 	<div class="form-horizontal">
	                <div class="form-group">
	                  <label for="" class="col-sm-4 control-label"><span class="required">*</span>申诉理由：</label>
	                  <div class="col-sm-8">
	                    <textarea rows="5" class="form-control" v-model="appeal.remark" placeholder="请填写申诉理由"></textarea>
	                  </div>
	                </div>
	              </div>
          	</div>
          	<div class="modal-footer">
            	<!--<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>-->
            	<button type="button" class="btn checkedBtn" v-show="btnShow" @click="saveAppeal">确定</button>
          	</div>
        </div>
      </div>
    </div>
</template>

<script>
	export default{
		//接收父组件的绑定值
		props: ["appealModal"],
		data() {
			return {
				//机构信息对象
				appeal: {
					remark: '',
				},
				btnShow: true
			}
		},
		watch: {
		},
		methods: {
			saveAppeal() {
				var _self = this;
				if(_self.appeal.remark == ""){
					layer.msg("请填写申诉理由");
					return false;
				}
				var reqData={
					cusPremisesId:this.appealModal.cusPremisesId,
					staffId:window.localStorage.getItem("4_userId"),
					remark:_self.appeal.remark
				}
				var body = {};
				body.params = reqData;
				var url = this.utilHelper.apiUrl+'/api/addAppeal.do';
				_self.$http.post(url,body).then((response)=>{
					var body = response.body.resData ;
					console.log("申诉");
					console.log(body);
					if(body.result=="1"){	
						layer.msg("提交成功!", {
								time: 1000
						}, function(){
							//关闭弹出层
							_self.btnShow = true;
							$('#addAppealModal').modal('hide');
							//子组件向父组件传递信号: 调用父组件中对子组件的监听
							_self.$emit('saveAppealListener');
						});
					}else{
						layer.msg(body.resultMsg, {
								time: 1000
						}, function(){
							//关闭弹出层
							_self.btnShow = true;
							$('#addAppealModal').modal('hide');
							//子组件向父组件传递信号: 调用父组件中对子组件的监听
							_self.$emit('saveAppealListener');
						});
					}
				},(response)=>{
					layer.alert("请求异常!");
				});
			}
		}
	}
	
</script>